from odoo import api, fields, models, _
from odoo.osv import expression

class ResPartner(models.Model):
    _inherit = 'res.partner'

    @api.model
    def name_search(self, name='', args=None, operator='ilike', limit=100):
        if self._context.get('sale_change_apply'):
            ids = self._name_search(name, args, operator, limit=limit, order=self._order)
            add_ids = self.search([('code', 'ilike', name), ('code', '!=', False)], limit=50)
            records = self.browse(ids)
            records |= add_ids
            display_names = [(rec.id, rec.display_name) for rec in records]
        else:
            display_names = super().name_search(name, args, operator, limit)
        return display_names
